package com.updateUser.controller;


import com.updateUser.payload.RestResult;
import com.updateUser.payload.UpdateUser;
import com.updateUser.entity.User;
import com.updateUser.service.impl.UserServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2021-09-06
 */
@RestController
@RequestMapping("/updateUser/user")
public class UserController{
    @Resource
    private UserServiceImpl userService;

    //查询操作
    @GetMapping("/search")
    public List<User> GetUser(){
        return userService.getAllUser();
    }

    //新增操作
    @PostMapping("/add")
    public RestResult addUser(@RequestBody User user) {
        return userService.addUser(user);
    }

    //修改操作
    @PostMapping("/update")
    public RestResult updateUser(@RequestBody UpdateUser updateUser) {
        return userService.updateUserById(updateUser);
    }

    //删除操作
    @PostMapping("/del")
    public RestResult delEnterpriseStatus(@RequestBody User user) {
        return userService.delUser(user.getId());
    }
}

